﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace HashLearn
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        
        private void button1_Click(object sender, EventArgs e)
        {
            testResult.Clear();
            Hashtable ht = new Hashtable();
            ht.Add(1,"lisa");
            ht.Add(2,"joey");
            ht.Add("Joey","Joey");
            testResult.Text += "Joey" + ht["Joey"].ToString();
        }

        //遍历HashTable
        private void button2_Click(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();
            ht.Add(1, "lisa");
            ht.Add(2, "joey");
            ht.Add("Joey", "Joey");

            foreach(DictionaryEntry de in ht)
            {
                testResult.Text+="Key:"+de.Key+"Value:"+de.Value+"\r\n";
            }
        }
    }
}
